<?php

namespace catchAdmin\logistics\controller;

use catcher\base\CatchRequest as Request;
use catcher\CatchResponse;
use catcher\base\CatchController;
use catchAdmin\logistics\model\Order as OrderModel;
use think\Response;


class Order extends CatchController
{
    
    protected $orderModel;
    
    /**
     *
     * @time 2021/11/08 11:25
     * @param OrderModel $orderModel
     * @return mixed
     */
    public function __construct(OrderModel $orderModel)
    {
        $this->orderModel = $orderModel;
    }
    
    /**
     *
     * @time 2021/11/08 11:25
     * @return Response
     */
    public function index(Request $request) : Response
    {
        return CatchResponse::paginate($this->orderModel->getList());
    }
    
    /**
     *
     * @time 2021/11/08 11:25
     * @param Request $request
     * @return Response
     */
    public function save(Request $request) : Response
    {
        return CatchResponse::success($this->orderModel->storeBy($request->post()));
    }
    
    /**
     *
     * @time 2021/11/08 11:25
     * @param $id
     * @return Response
     */
    public function read($id) : Response
    {
        return CatchResponse::success($this->orderModel->findBy($id));
    }
    
    /**
     *
     * @time 2021/11/08 11:25
     * @param $id
     * @param Request $request
     * @return Response
     */
    public function update($id, Request $request) : Response
    {
        return CatchResponse::success($this->orderModel->updateBy($id, $request->post()));
    }
    
    /**
     *
     * @time 2021/11/08 11:25
     * @param $id
     * @return Response
     */
    public function delete($id) : Response
    {
        return CatchResponse::success($this->orderModel->deleteBy($id));
    }
}